<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@head>
<link rel="stylesheet" href="/misc/app/css/product_list.css"/>
</@head>

<@body>
<script src="/misc/app/js/prize_list.js"></script>
</@body>

<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${prizeList.resultTotal} 条记录</span>
        <form class="form-inline" action="/prize" name="form_query_prize">
            <div class="input-group">
                <div class="input-group-addon">关键字</div>
                <input type="text" class="form-control" style="width: 260px" name="name" value="${name!}" placeholder="奖品名称"/>
            </div>
			<div class="input-group">
                <div class="input-group-addon">奖品类型</div>
                <select class="form-control" name="type">
                    <option value="">全部</option>
                    <option value="1" ${(type?exists && type == 1)?string("selected","")}>红包</option>
                    <option value="2" ${(type?exists && type == 2)?string("selected","")}>实物</option>
                    <option value="3" ${(type?exists && type == 3)?string("selected","")}>优惠券</option>
                </select>
            </div>
            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" id="search_reset" class="btn btn-warning"><i class="fa"></i> 重置</button>
        	<button type="button" class="btn btn-default" name="btn_new_prize"><i class="fa fa-plus"></i> 新增奖品</button>
        </form>
        <form class="form-inline hide">
            <input class="form-control"/>
            <input type="email" class="form-control"/>
            <button type="submit" class="btn btn-default">Send invitation</button>
        </form>
    </div>

    <!-- /.box-header -->
    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>奖品名称</th>
                <th>奖品类型</th>
                <th>奖品价格</th>
                <th>奖品库存</th>
                <th>中奖数量</th>
                <th>兑奖数量</th>
                <th>创建时间</th>
                <th>创建人</th>
                <th>操作</th>
            </tr>
            <#list prizeList.result as item>
                <tr>
                    <td>${item.id}</td>
                    <td>${item.name}</td>
                    <td><#if item.type==1><span class="text-green">红包</span><#elseif item.type==2><span class="text-yellow">实物</span><#elseif item.type == 3><span class="text-danger">优惠券</span></#if></td>
                    <td>${item.price?string('0.00')}</td>
                    <td>${item.stock}</td>
                    <td>${item.winNub!}</td>
                    <td>${item.cashNub!}</td>
                    
                    <td>${item.cTime?number_to_datetime}</td>
                    <td>${item.cAdmin}</td>
                    <td>
                    	<button type="button" class="btn btn-default btn-xs" name="btn_edit_prize" data-prize-number="${item.id?c}">编辑</button>
                    	<!--<#if item.delFlag?exists>
                    		<#if item.delFlag == 0>
                    			<button type="button" class="btn btn-default btn-xs" name="btn_delete_prize" data-prize-id="${item.id?c}">删除</button>
                    		</#if>
                    	</#if> -->
                        
                    </td>
                </tr>
            </#list>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/prize?name=${name!}&page=$page",prizeList.page,prizeList.pageTotal/>
    </div>
</div>



<div class="modal" id="md_edit_prize" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"><i class="fa fa-pencil-square-o"></i> 编辑奖品</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_prize">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 奖品名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="name"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 奖品类型</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="type">
                                <option value="1">红包</option>
                                <option value="2">实物</option>
                                <option value="3">优惠券</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 价格</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="price"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 库存</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="stock"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 配送方式</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="shippingMethod">
                                <option value="1">自动发送</option>
                                <option value="2">上门自提</option>
                                <option value="3">物流发送</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 简介</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="summary"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_prize">保存</button>
            </div>
        </div>
    </div>
</div>

</@layout_default>